﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Salomon/MP/Base.Master" AutoEventWireup="true" CodeBehind="CatCreate.aspx.cs" Inherits="WebsiteAdmin.Salomon.ProInfo.CatCreate" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="server">新建分类 - 产品</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head_Meta" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Head_Css" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Head_Script" runat="server">
    <script type="text/javascript" src="/Script/Mootools.Smoothbox.js"></script>
	<script type="text/javascript" src="/CKFinder/CKFinder.js"></script>
<script type="text/javascript" language="javascript">
    var MenuViewID = 2;
	window.addEvent('domready', function() {
        $('submitbtn').addEvent('click', function() {
            Submit();
        });
        
        $('ShowLink').addEvent('click', function() {
            BrowseServer('Images:/Category/', 'txbImgURL', 'ShowView');

        });
        
    });
    
    function SetFileField(fileUrl, data) {
        $(data["selectActionData"]).value = fileUrl;
        $(this).setProperty('src', fileUrl);
    }
    function BrowseServer(startupPath, functionData, element) {
        var finder = new CKFinder();
        finder.startupPath = startupPath;
        finder.selectActionData = functionData;
        finder.selectActionFunction = SetFileField.bind(element);
        finder.popup();
    }
    
	function Submit() {
        var txbCatTitle = $('txbCatTitle').get('value').trim();
        if (txbCatTitle.length == 0) {
            alert('分类标题错误');
            return false;
        }
        var txbUrlName = $('txbUrlName').get('value').trim();
        var txbImgURL  = $('txbImgURL').get('value').trim();
        var txbDescription = $('txbDescription').get('value').trim();
        var txbSortOrder = $('txbSortOrder').get('value').trim().toInt();
        if (isNaN(txbSortOrder)) {
            alert('必须是整数');
            return false;
        }
        Insert(
        txbCatTitle,
        txbUrlName,
        txbImgURL,
        txbDescription,
        txbSortOrder);
    }

    function Insert(txbCatTitle,
        txbUrlName,
        txbImgURL,
        txbDescription,
        txbSortOrder) {

        new Request.JSON({
            method: 'post',
            url: 'Handler/CatInsert.ashx',
            data: {
                ParID: <%=pkid %>,
                CatRank: <%=catRank %>,
                CatTitle: txbCatTitle,
                UrlName: txbUrlName,
                ImgURL:txbImgURL,
                Description: txbDescription,
                SortBy: txbSortOrder
            },
            noCache: true,
            onSuccess: function(data, text) {
                if (data.Done == 'Success') { 
                    
                    if(confirm('添加成功，返回列表？'))
                    {
                        document.location.href = '/Salomon/ProInfo/CatList.aspx';
                    };
                    LightBox.remove();
                }
                else
                {
                    alert('添加失败');
                    LightBox.remove();
                }
            },
            onFailure: function(xhr) {
                alert(xhr.statusText);
                LightBox.remove();
            }
        }).send();
    }
		
		
</script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Body_Top" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Body_Content" runat="server">
      <div class="infobox">
      <h3>
        <span>创建分类</span>
			<a href="/Salomon/ProInfo/CatList.aspx" class="back action">返回一级分类列表</a> <a href="/Salomon/ProInfo/CatList.aspx?pid=<%=parID %>" class="back action">返回分类列表</a>
        </h3>
        <div class="pd05">
        <form id="myForm" action="">
		    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
		        <tr>
            		<td align="right" width="100">所属分类：</td>
            		<td>
            			<%=parName%> | <a href="/Salomon/ProInfo/CatList.aspx?pid=<%=parID %>" >查看子级</a>
            		</td>
				</tr>
				<tr>
            		<td align="right" width="100">分类级别：</td>
            		<td>
            			<%=catRank %>
            		</td>
				</tr>
		        <tr>
            		<td align="right" width="100"><span class="Need">分类标题：</span></td>
            		<td>
            			<input name="txbCatTitle" type="text" id="txbCatTitle" maxlength="20" size="10" value="" />
            			<i>限10个汉字</i>
            		</td>
				</tr>
				<tr>
            		<td align="right" width="100"><span class="Need">显示链接：</span></td>
            		<td>
            			<input name="txbUrlName" type="text" id="txbUrlName" maxlength="20" size="20" value="" /><i>.html
            			限20个字符，例 service、fuwu</i>
            		</td>
				</tr>
				<tr>
                    <td align="right" width="100">
                        图片：</td>
                    <td>
                           <input type="text" id="txbImgURL" name="txbImgURL" style="width:450px; color:#666; background-color:#efefef; border:1px #ccc solid;" readonly="readonly" value=""  /> <font color="red">*&nbsp;</font>
                           <a id="ShowLink" style="cursor:pointer;cursor:hand;border:solid 1px;padding:0 10px 0 10px;">浏览</a>
                    </td>
                </tr>
                <tr>
                    <td align="right" width="100">&nbsp;</td>
                    <td>
                        <div style=" width:329px; height:159px; overflow:hidden; border:1px #999 solid; background-color:#f8f8f8; clear:both;">
                           <img id="ShowView" alt="" src="/images/view.png" />
                        </div>
                        <i>图片尺寸 329 x 159。一级分类不需要添加图片</i><br />
                        <i>如果图片不能完全填充，请重新选择图片。</i>
                    </td>
                </tr>
				<tr>
            		<td align="right" width="100"><span class="Need">简介：</span></td>
            		<td>
            			<textarea name="txbDescription" rows="3" cols="20" id="txbDescription"></textarea>
            		</td>
				</tr>
				<tr>
            		<td align="right" width="100"><span class="Need">显示排序：</span></td>
            		<td>
            			<input name="txbSortOrder" type="text" id="txbSortOrder" maxlength="2" size="5" value="50" />
            			<i>请输入数字</i>
            		</td>
				</tr>
		    </table>
		    <table border="0" cellpadding="0" cellspacing="0" class="table_form">
				<tr>
					<td width="100" height="40">&nbsp;</td>
					<td>
						<input id="submitbtn" type="button" value="提交" class="btn" />
						<input type="reset" value="重置" class="btn" />
					</td>
				</tr>
			</table>
		</form>
        </div>
</div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Body_Foot" runat="server"  >
</asp:Content>